package com.wenwu.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.wenwu.common.bean.RelicsProtectBasic;
import com.wenwu.common.bean.RelicsProtectBasicExample;
import com.wenwu.common.exception.RelicsException;
import com.wenwu.common.utils.CreateRelicsProtectAreaBean;
import com.wenwu.dao.RelicsHumanityEnvironmentMapper;
import com.wenwu.dao.RelicsProtectBasicMapper;
import com.wenwu.service.RelicsProtectBasicService;

@Service
public class RelicsProtectBasicServiceImpl implements RelicsProtectBasicService {

	@Autowired
	private RelicsProtectBasicMapper relicsProtectBasicMapper;
	
	public Integer addObj(RelicsProtectBasic relicsProtectBasic)
			throws RelicsException {
		try {
			Integer primaryKey= null;
			if (relicsProtectBasic.getProtectBasicId() == null) {
				primaryKey = relicsProtectBasicMapper.insertSelective(relicsProtectBasic);
				return primaryKey;			
			} else {
				RelicsProtectBasicExample example = new RelicsProtectBasicExample();
				example.createCriteria().andProtectBasicIdEqualTo(relicsProtectBasic.getProtectBasicId());
				primaryKey = relicsProtectBasicMapper.updateByExampleWithBLOBs(relicsProtectBasic, example);
				return primaryKey;
			}
		} catch (Exception e) {
			throw new RelicsException("系统异常");
		}
	}

	public RelicsProtectBasic selectObjByKey(Integer protectBasicId)
			throws RelicsException {
		RelicsProtectBasicExample example = new RelicsProtectBasicExample();
		example.createCriteria().andProtectBasicIdEqualTo(protectBasicId);
		return (RelicsProtectBasic) relicsProtectBasicMapper.selectByExampleWithBLOBs(example);
	}

	public int deleteByKey(List<?> keys) throws RelicsException {
		/*try {
			return relicsProtectBasicMapper.deleteByKey(keys);
		} catch (Exception e) {
			throw new RelicsException("系统异常");
		}*/
		return 0;
	}

}
